home *** CD-ROM | disk | FTP | other *** search
/ STraTOS 1997 April & May / STraTOS 1 - 1997 April & May.iso / CD01 / INTERNET / SITES / GRAHAM / XA_6S.ZIP / SOURCE / TITLWIDG.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-18  |  5.8 KB  |  227 lines

  1. /*
  2.  * XaAES - XaAES Ain't the AES
  3.  *
  4.  * A multitasking AES replacement for MiNT
  5.  *
  6.  */
  7.  
  8. #include <OSBIND.H>
  9. #include <MINTBIND.H>
  10. #include <VDI.H>
  11. #include "XA_TYPES.H"
  12. #include "XA_DEFS.H"
  13. #include "XA_GLOBL.H"
  14. #include "KERNAL.H"
  15. #include "K_DEFS.H"
  16. #include "GRAF_MOU.H"
  17. #include "MESSAGES.H"
  18. #include "C_WINDOW.H"
  19. #include "RECTLIST.H"
  20. #include "ALL_WIDG.H"
  21. #include "STD_WIDG.H"
  22. #include "drag_box.h"
  23. #include "SYSTEM.H"
  24. #include "OBJECTS.H"
  25. #include "BOX3D.H"
  26.  
  27. /*======================================================
  28.     TITLE WIDGET BEHAVIOUR
  29. ========================================================*/
  30. short display_title(XA_WINDOW *wind, XA_WIDGET *widg)
  31. {
  32.     short x,y,pnt[6];
  33.  
  34.     rp_2_ap(wind, widg, &x, &y);    /* Convert relative coords and window location to absolute screen location */
  35.  
  36.     vswr_mode(V_handle, MD_TRANS);
  37.  
  38. #if DISPLAY_LOGO_IN_TITLE_BAR
  39.     if (widg->stat==XAW_PLAIN)
  40.         def_widgets[WIDG_LOGO].ob_state&=~SELECTED;
  41.     else
  42.         def_widgets[WIDG_LOGO].ob_state|=SELECTED;
  43.     
  44.     display_object(def_widgets,WIDG_LOGO,x,y);
  45.  
  46.     x+=ICON_W+3;
  47.  
  48.     pnt[0]=x; pnt[1]=y; pnt[2]=x+widg->w-ICON_W-6; pnt[3]=y+widg->h;
  49. #else
  50.     pnt[0]=x; pnt[1]=y; pnt[2]=x+widg->w-3; pnt[3]=y+widg->h;
  51. #endif
  52.  
  53. #if 0
  54.     if (window_list==wind)    /* Highlight the title bar of the top window */
  55.     {
  56.         vsf_color(V_handle,LBLUE);
  57.         vsf_interior(V_handle,FIS_SOLID);
  58.         v_bar(V_handle,pnt);
  59.         vst_color(V_handle,WHITE);
  60.     }else{
  61.         vst_color(V_handle,BLACK);
  62.     }
  63. #else
  64.     if (window_list==wind)    /* Highlight the title bar of the top window */
  65.         vst_color(V_handle,BLACK);
  66.     else
  67.         vst_color(V_handle,WHITE);
  68.     
  69.     if (widg->stat==XAW_PLAIN)
  70.         vsl_color(V_handle,display.dial_colours.t_l_col);
  71.     else
  72.         vsl_color(V_handle,display.dial_colours.b_r_col);
  73.  
  74.     pnt[0]=x+widg->w; pnt[1]=y;
  75.     pnt[2]=x; pnt[3]=y;
  76.     pnt[4]=x; pnt[5]=y+widg->h;
  77.     v_pline(V_handle,3,pnt);
  78.  
  79.     if (widg->stat==XAW_PLAIN)
  80.         vsl_color(V_handle,display.dial_colours.b_r_col);
  81.     else
  82.         vsl_color(V_handle,display.dial_colours.t_l_col);
  83.  
  84.     pnt[2]=x+widg->w; pnt[3]=y+widg->h;
  85.     v_pline(V_handle,3,pnt);
  86. #endif
  87.  
  88.     v_gtext(V_handle, x+5,y, (char*)widg->stuff);
  89.  
  90.     return TRUE;
  91. }
  92.  
  93. /* Click & drag on the title bar - does a move window */
  94. short drag_title(XA_WINDOW *wind, XA_WIDGET *widg)
  95. {
  96.     short x,y;
  97.     XA_WINDOW *scan_wind;
  98.  
  99.     if (wind!=window_list)    /* Don't allow windows below a STORE_BACK to move */
  100.     {
  101.         for(scan_wind=wind->prev; scan_wind; scan_wind=scan_wind->prev)
  102.         {
  103.             if (scan_wind->active_widgets&STORE_BACK)
  104.                 return TRUE;
  105.         }
  106.     }
  107.  
  108.     if (wind->active_widgets&MOVER)            /* You can only move a window if it's MOVER attribute is set */
  109.     {
  110.         vs_clip(V_handle, 0, NULL);
  111.  
  112.         graf_mouse(XACRS_MOVER, NULL);        /* Always have a nice consistent MOVER when dragging a box */
  113.         drag_box(wind->w, wind->h, wind->x, wind->y, -display.x, display.y, display.w*4, display.h*2, &x, &y);
  114.         
  115.         graf_mouse(clients[window_list->owner].client_mouse, clients[window_list->owner].client_mouse_form);    /* Restore the mouse now we've done the drag */
  116.  
  117.         if ((x!=wind->x)||(y!=wind->y))
  118.         {
  119.             if (wind->active_widgets&NO_MESSAGES)    /* Just move these windows, they can handle it.... */
  120.             {
  121.             
  122.                 move_window(wind,x,y,wind->w,wind->h);
  123.                 
  124.             }else{    /* Send a message to a client to say that the AES would like the window moving (if the window has moved) */
  125.  
  126.                 send_app_message(wind->owner, WM_MOVED, 0, wind->handle, x, y, wind->w, wind->h);
  127.  
  128.             }
  129.         }
  130.     }
  131.     
  132.     return TRUE;
  133. }
  134.  
  135. /* Single click title bar sends window to the back */
  136. short click_title(XA_WINDOW *wind, XA_WIDGET *widg)
  137. {
  138.     short clipV[4];
  139.     XA_WINDOW *wl;
  140.     GRECT clip,our_win;
  141.  
  142.     if (window_list!=wind)    /* If window isn't top then top it */
  143.     {
  144.     
  145.         if (wind->active_widgets&NO_MESSAGES)    /* Just top these windows, they can handle it.... */
  146.         {
  147.             pull_wind_to_top(wind);    /* Top the window */
  148.  
  149.             for(wl=wind; wl; wl=wl->next)
  150.                 generate_rect_list(wl);
  151.  
  152.             clipV[0]=wind->x; clipV[1]=wind->y;
  153.             clipV[2]=wind->x+wind->w; clipV[3]=wind->y+wind->h;
  154.             vs_clip(V_handle,1,clipV);
  155.  
  156.             v_hide_c(V_handle);
  157.             display_window(wind);    /* Display the window (clip to it's size) */
  158.             v_show_c(V_handle,1);
  159.             
  160.             vs_clip(V_handle,0,clipV);
  161.     
  162.         }else{
  163.     
  164.             send_app_message(wind->owner, WM_TOPPED, 0, wind->handle, 0, 0, 0, 0);
  165.     
  166.         }
  167.     
  168.     }else{        /* If window is already top, then send it to the back */
  169.  
  170.         if (!(wind->active_widgets&STORE_BACK))    /* Don't bottom STORE_BACK windows */
  171.         {
  172.             if (wind->active_widgets&NO_MESSAGES)
  173.             {
  174.                 v_hide_c(V_handle);
  175.                 Psemaphore(2,WIN_LIST_SEMAPHORE,-1L);
  176.  
  177.                 send_wind_to_bottom(wind);            /* Send it to the back */
  178.                         
  179.                 display_non_topped_window(wind, NULL);    /* Re-display new top window */
  180.  
  181.                 v_show_c(V_handle,1);
  182.  
  183.                 our_win.g_x=wind->x; our_win.g_y=wind->y;
  184.                 our_win.g_w=wind->w; our_win.g_h=wind->h;
  185.             
  186.                 for(wl=wind->prev; wl->prev; wl=wl->prev)
  187.                 {
  188.                     clip.g_x=wl->x; clip.g_y=wl->y;
  189.                     clip.g_w=wl->w; clip.g_h=wl->h;
  190.                 
  191.                     if (rc_intersect(&our_win,&clip))
  192.                     {
  193.                         display_non_topped_window(wl,&clip);    /* Re-display any revealed windows */            
  194.                         send_app_message(wl->owner, WM_REDRAW, 0, wl->handle, clip.g_x, clip.g_y, clip.g_w, clip.g_h);
  195.                     }
  196.                 }
  197.                 display_non_topped_window(wl, NULL);    /* Re-display new top window */
  198.  
  199.             }else{
  200.  
  201.                 send_app_message(wind->owner, WM_BOTTOMED, 0, wind->handle, 0, 0, 0, 0);
  202.  
  203.             }
  204.         }
  205.     }
  206.     
  207.     return TRUE;
  208. }
  209.  
  210. /* Double click title bar of iconified window - sends a restore message */
  211. short dclick_title(XA_WINDOW *wind, XA_WIDGET *widg)
  212. {
  213.     if (wind->active_widgets&NO_MESSAGES)
  214.     {
  215.         return FALSE;
  216.     }
  217.     
  218. /* If window is iconified - send request to restore it */
  219.     if (wind->window_status==XAWS_ICONIFIED)
  220.     {
  221.         send_app_message(wind->owner, WM_UNICONIFY, 0, wind->handle, wind->prev_x, wind->prev_y, wind->prev_w, wind->prev_h);
  222.     }
  223.     
  224.     return TRUE;
  225. }
  226.  
  227.